#include <math.h>
#include <iostream>
using std::cout;
using std::endl;
//友元之成员函数的形式
//如果有多个类的情况下，谁声明为谁的友元呢？
//如果Line需要访问Point的私有数据成员
class Point;
class Line{
public:
    //解决方案是将该函数的实现放到Point的类后面去实现
    float distance(const Point & lhs,const Point & rhs);
    //{
        //让Point提供公有的get函数i
        //sqrt(a *a + b * b)
      //  int x = lhs._x - rhs._x;
       // int y = lhs._y - rhs._y;
        //return sqrt(pow(x , 2) + pow(y, 2));
    //}
private:
    int _flag;
};
class Point{
public:
    Point(int x, int y)
    :_x(x)
    ,_y(y)
    {

    }

    void func(Line line){
        cout << line._flag << endl;
    }

private:
    friend float Line::distance(const Point & lhs, const Point & rhs);
    int _x;
    int _y;
};   
float Line::distance(const Point & lhs,const Point & rhs){
        int x = lhs._x - rhs._x;
        int y = lhs._y - rhs._y;
        return sqrt(pow(x , 2) + pow(y, 2));
}



void test(){
    Line line;
    float result = line.distance(Point(1, 1), Point(4, 5));
    cout << result << endl;
}

int main()
{
    test();
    return 0;
}

